#ifndef IDATABASE_H
#define IDATABASE_H

#include <QObject>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDataWidgetMapper>

class IDatabase : public QObject
{
    Q_OBJECT
public:
    static IDatabase& getInstance()
    {
        static IDatabase instance; // Guaranteed to be destroyed.
            // Instantiated on first use.
        return instance;
    }
    // 登录方法
    QString userLogin(QString userName,QString password);
    //初始化数据模型
    bool initPatientModel();
    int addNewPatient();
    bool searchPatient(QString filter);
    bool deletePatient();
    bool submitPatient();
    void revertPatient();


private:
    explicit IDatabase(QObject *parent = nullptr);
    IDatabase(IDatabase const&)               = delete;
    void operator=(IDatabase const&)  = delete;
    void initDataBase();


    QSqlDatabase database;

signals:

public:
    QSqlTableModel  *patientTabModel;          //数据模型
    QItemSelectionModel *thePatientSelModel;	//选择模型

};

#endif // IDATABASE_H
